define(['jquery','bootstrap'],function($){
    function RegisterModal(){
        this.render();
        this.addListener();
    }
    $.extend(RegisterModal.prototype,{
        render:function(){
            $('.registerBox').load('../html/header-modal.html #regModal ',$.proxy(this.addListener,this))
        },
        addListener(){
            $("#onReg").on('click',this.registerHandler);
            //两次密码是否一致
            $("#rePassword").on('blur',this.isEqual)
        },
        isEqual(event){
            if($(event.target).val() !==$("#password").val()){
                $(".repassword-error").removeClass('hidden');
            }else{
                $(".repassword-error").addClass('hidden');
            }

        },
        registerHandler(){
           
            const url='/api/users/register',
            data=$("#registerForm").serialize();
           
            $.post(url,data,function(data){
                console.log(data);
            })
        }
        
       
    })
    return new RegisterModal();
})